import  requests




class SendMethod():

    @staticmethod
    def send_method(method, url, params=None, data=None, json=None, headers=None):
        if method in ['get','post']:
            response=requests.request(method=method,url=url,params=params,data=data,json=json,headers=headers)
        else:
            response=None
            print('请求发送错误,请重新选择')

        result = {}
        if response is not None:
            result['status_code'] = response.status_code
            result['headers'] =response.headers
            result['body']=response.json()
            result['response_time']=int(response.elapsed.microseconds/1000)
            return  result
        else:
            return response

if __name__ == '__main__':
    method ='post'
    url ='http://47.108.206.100:8080/admin/login'
    login_data={
        'username':'admin',
        'password':'macro123'
    }
    print(SendMethod.send_method(method=method,url=url,json=login_data))



